<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<script type="text/javascript">
	var achievementMenvTree;
	var achievementMenvTree_url='';
	var layout_west_tree;
	var layout_west_tree_url = '';
	var layout_west_accordion;
	
	var sessionInfo_userId = '${sessionInfo.userId}';
	//console.log("sessionInfo_userId="+sessionInfo_userId);
	var layout_west_menuTreeUrl = '${pageContext.request.contextPath}/resourceController/menuTree';
	
	//console.log(layout_west_menuTreeUrl);
	//
	
	function appendTreeMenu(){
		console("create and append TreeMenu.");
	};

	function createAccordionPanels(accordionPanelJson){
		JqLayoutWestAccordion=$('#layout_west_accordion');
		$.each(accordionPanelJson,function(index,panel){
			var panelDiv=$('<div></div>');
			panelDiv.attr({		
			'id':panel.id, 
			'title':panel.name,
			'data-options':"border:false,iconCls:'anchor'"
			});
			var treeDivId="layout_west_panel_tree_div_"+panel.id;
			var treeDiv=$('<div class="well well-small"><ul id='+treeDivId+'></ul></div>');
			panelDiv.append(treeDiv);

			console.log($("#"+treeDivId));
			console.log(panel);
			layout_west_accordion.append(panelDiv);	
			appendTreeMenu();
		});
	}
	
	
	
	$(function() {
		
		//获得模块数据 
		var moduleArray;
		$.ajax({ 
		   url: '${pageContext.request.contextPath}/layout/west/accordionPanel.json', 
		   beforeSend:function() {
						parent.$.messager.progress({
							title : '提示',
							text : '数据处理中，请稍后!!!!'
						});
		 	},
			complete:function(data) {
				parent.$.messager.progress('close');
				 
		 	},
		   success: function(accordionPanelJson) {
			   console.log(moduleList);
			   parent.$.messager.progress('close');
			   createAccordionPanels(accordionPanelJson);
			   //accordion 组织完成后，生成该模块
				$('#layout_west_accordion').accordion({    
				    animate:true   
				});  
			  
		 	},
		   error: function(data) {
			         alert("模块读取异常！");
					}
			});
		
		 /*   console.log(moduleArray); */
		 console.log("end fun");
		 
		 
		 
	});

	function addTab(params) {
		var iframe = '<iframe src="' + params.url + '" frameborder="0" style="border:0;width:100%;height:98%;"></iframe>';
		var t = $('#index_tabs');
		var opts = {
			title : params.title,
			closable : true,
			iconCls : params.iconCls,
			content : iframe,
			border : false,
			fit : true
		};
		if (t.tabs('exists', opts.title)) {
			t.tabs('select', opts.title);
			parent.$.messager.progress('close');
		} else {
			t.tabs('add', opts);
		}
	}
</script>
<div id='layout_west_accordion'  data-options="fit:true,border:false">
	
</div>